package server

import (
	"context"
	"longmen/server/internal/rpc/tencentim/imsdk"
	pb "longmen/server/pkg/protobuf"

	"longmen/server/pkg/common/api_models"
)

func (s *Server) RoomBoardcast(ctx context.Context, r *pb.RoomBoardcastReq) (*pb.RoomBoardcastResp, error) {
	req := &api_models.RoomBoardcastReq{
		Type:    r.Type,
		Content: r.Content,
		Contact: r.Contact,
		RoomID:  r.RoomId,
	}
	err := imsdk.GetSdk().BroadcastInterface(int(r.RoomId), req, 3)

	if err != nil {
		return &pb.RoomBoardcastResp{
			Message: err.Error(),
		}, err
	}

	return &pb.RoomBoardcastResp{
		Message: "ok",
	}, nil
}
